package com.weavernorth.retailExperienceAward.utils;

import weaver.conn.RecordSet;
import weaver.general.Util;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.List;

/**
 * @Author: bruseewang
 * @Package: com.weavernorth.retailExperienceAward.utils
 * @date: 2020/6/18 13:35
 * @description:
 */
public class commonsUtil {
    /***
     * 根据休假天数发放对应档次的奖金
     * @param amount
     * @param xjDays
     * @return
     */
    public static Double convertAmount(Double amount,Double xjDays){
        Double result=0.00;
        //休假天数在7天内,奖金总额100%发放
        if (Double.doubleToLongBits(xjDays)<=Double.doubleToLongBits(7)){
            result=amount;
        }else if(Double.doubleToLongBits(xjDays)>Double.doubleToLongBits(15)){
            //休假天数大于等于15天，奖金全部扣除
            result=0.0;
        }else{
            //休假天数在7-15天,含15天,奖金发放50%
            result=amount*0.5;
        }
        return result;
    }
    /***
     * double类型数字只保留2位小数
     * @param va1
     * @return
     */
    public static Double doubleFormat(Double va1){
        BigDecimal bd=new BigDecimal(va1);
        BigDecimal bd1=bd.setScale(2, BigDecimal.ROUND_HALF_UP);
        Double result=Double.parseDouble(bd1.toString());
        return result;
    }
}
